from google.appengine.ext import webapp
from common import *

class Gallery(webapp.RequestHandler):
    def get(self):
        check_user(self)
        self.response.out.write('<html><body><a href="/">Back to home</a><br />')
        
        photos = Photo.all();
        for photo in photos:
            
        
        self.response.out.write('<form action="/gallery" method="post" enctype="multipart/form-data">')
        self.response.out.write('Title <input type="text" name="title" /><br />')
        self.response.out.write('Description <input type="text" name="desc" /><br />')
        self.response.out.write('File <input type="file" name="photo" /><br />')
        self.response.out.write('<input type="submit" name="submit" /><br />')
        self.response.out.write('</form>')
        
    def post(self):
        check_user(self)
        photo = Photo() 
        photo.title = self.request.get('title')
        photo.desc = self.request.get('desc')
        photo.data = self.request.get('photo')
        photo.put()
            